package me.ingxin.android.tools

import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentActivity
import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider

inline fun <reified T : ViewModel> Fragment.lazyViewModel(): Lazy<T> {
    return lazy { ViewModelProvider(this)[T::class.java] }
}

inline fun <reified T : ViewModel> FragmentActivity.lazyViewModel(): Lazy<T> {
    return lazy { ViewModelProvider(this)[T::class.java] }
}